#ifndef __WHIMSY_ARCHIVE_HPP__SHANHAOBO_19800429__
#define __WHIMSY_ARCHIVE_HPP__SHANHAOBO_19800429__

#include "../Config/WhimsyDataType.hpp"
#include "./WhimsyObjectBase.hpp"

namespace Whms
{
    namespace Archive
    {
        struct Type : public ::Whms::Object::Base::Type
        {
            //////////////////////////////////////////////////////////////////////////

            virtual ::Whms::Size::Type ReadFrom(::Whms::Int8::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Int16::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Int32::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Int64::In) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type ReadFrom(::Whms::UInt8::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::UInt16::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::UInt32::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::UInt64::In) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type ReadFrom(::Whms::Real32::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Real64::In) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type ReadFrom(::Whms::Vec2::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Vec3::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::Vec4::In) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type ReadFrom(::Whms::IntVec2::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::IntVec3::In) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type ReadFrom(::Whms::IntVec4::In) = WIZ_NULLPTR;
        
            template<class ElementT>
            ::Whms::Size::Type ReadFromArray(::Wiz::Array::Type<ElementT>& InArray)
            {
                ::Whms::UInt32::TypeConst ArrSz= InArray.Size();
                ::Whms::Size::Type RetSz = ReadFrom(ArrSz);
                for (::Whms::UInt32::Type i = 0; i < ArrSz; ++i)
                {
                    RetSz += ReadFrom(InArray[i]);
                }

                return RetSz;
            }

            //////////////////////////////////////////////////////////////////////////

            virtual ::Whms::Size::Type WriteTo(::Whms::Int8::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Int16::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Int32::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Int64::Out) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type WriteTo(::Whms::UInt8::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::UInt16::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::UInt32::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::UInt64::Out) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type WriteTo(::Whms::Real32::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Real64::Out) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type WriteTo(::Whms::Vec2::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Vec3::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::Vec4::Out) = WIZ_NULLPTR;

            virtual ::Whms::Size::Type WriteTo(::Whms::IntVec2::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::IntVec3::Out) = WIZ_NULLPTR;
            virtual ::Whms::Size::Type WriteTo(::Whms::IntVec4::Out) = WIZ_NULLPTR;


            template<class ElementT>
            ::Whms::Size::Type WriteToArray(::Wiz::Array::Type<ElementT>& OutArray)
            {
                ::Whms::UInt32::Type ArrSz = 0;
                ::Whms::Size::Type RetSz = WriteTo(ArrSz);

                for (::Whms::UInt32::Type i = 0; i < ArrSz; ++i)
                {
                    ElementT TempEle;

                    RetSz += WriteTo(TempEle);

                    OutArray.PushBack(TempEle);
                }

                return RetSz;
            }

            //////////////////////////////////////////////////////////////////////////
        };

        WIZ_DECLARE(::Whms::Archive::Type);
    } /// end of namespace Archive
} /// end of namespace Whms

#endif /*__WHIMSY_ARCHIVE_HPP__SHANHAOBO_19800429__*/
